home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c,comp.std.c
- Path: hobbes.sco.COM!scocan!john
- From: john@sco.com (John R MacMillan)
- Subject: Re: Integral conversion e.t.c. (was: Re: Hungarian notation)
- Organization: SCO Canada, Inc.
- Date: Tue, 30 Jan 1996 20:40:29 GMT
- Message-ID: <DM0HFI.GEA@sco.COM>
- References: <30C40F77.53B5@swsbbs.com> <KANZE.96Jan29121956@slsvewt.lts.sel.alcatel.de> <4eindq$eju@solutions.solon.com> <DLzK76.88@ukpsshp1.serigate.philips.nl>
- Sender: news@sco.COM (News administration)
-
- |However if having perfomed the correct incantation - if the compiler fails
- |to give a diagnostic required by the standard then that is a bug in the
- |compiler - even if it then goes on to generate useful code. The whole point
- |about a standard compiler is that if code compiles clean on one, it should
- |compile clean on all.
-
- Unless you mean something different by ``clean'' than I do (no
- diagnostics), then I have to disagree, for two reasons. One is that a
- compiler that conforms to the standard is not obliged to catch non-
- conforming programs, so a clean compile does not mean a conforming
- program. The other reason is that a standard compiler is free to
- issue diagnostics that are not required as a quality-of-implementation
- matter.
-
- Consider the following (poorly written) module:
-
- #include <stdio.h>
- #include <stlib.h>
-
- int increment(int n)
- {
- int m;
-
- m = n + 1;
- if (m < n) {
- exit(EXIT_FAILURE);
- puts("This never gets printed");
- } else {
- return m;
- }
-
- puts("This never gets printed either");
- }
-
- A conforming compiler may note that exit() never returns and remark
- about unreachable code, or it may not, and remark that control could
- reach the end of the function without a return, or it might compile
- with no diagnostics at all (in fact I've seen implementations that
- match all of these behaviours). And I don't imagine anyone would
- expect it diagnose that the ``n + 1'' might overflow, resulting in
- undefined runtime behaviour but it could.
-
- So even if it compiles clean with my compiler, I can't expect it to do
- so with yours, and I can't even expect that the program is conforming.
-